Hybrid parallelization strategies for machine learning programs on top of MapReduce

ABSTRACT

Hybrid parallelization strategies for machine learning programs on top of MapReduce are provided. In one embodiment, a method of and computer program product for parallel execution of machine learning programs are provided. Program code is received. The program code contains at least one parallel for statement having a plurality of iterations. A parallel execution plan is determined for the program code. According to the parallel execution plan, the plurality of iterations is partitioned into a plurality of tasks. Each task comprises at least one iteration. The iterations of each task are independent.

BACKGROUND

Embodiments of the present invention relate to parallel execution ofmachine learning programs, and more specifically to hybridparallelization strategies for machine learning programs on top ofMapReduce.

BRIEF SUMMARY

According to one embodiment of the present invention, a method of andcomputer program product for parallel execution of machine learningprograms are provided. Program code is received. The program codecontains at least one parallel for statement having a plurality ofiterations. A parallel execution plan is determined for the programcode. According to the parallel execution plan, the plurality ofiterations is partitioned into a plurality of tasks. Each task comprisesat least one iteration. The iterations of each task are independent.

BRIEF DESCRIPTION OF THE SEVERAL VIEWS OF THE DRAWINGS

FIG. 1 depicts an exemplary SystemML Architecture according toembodiments of the present disclosure.

FIG. 2 depicts an directed acyclic graph of high level operators aftercommon subexpression elimination according to embodiments of the presentdisclosure.

FIG. 3A illustrates the architecture of a ParFOR execution strategyproviding local parallelism according to embodiments of the presentdisclosure.

FIG. 3B illustrates the architecture of a ParFOR execution strategyproviding remote parallelism according to embodiments of the presentdisclosure.

FIGS. 4A-C illustrate exemplary hybrid parallelization strategyaccording to various embodiments of the present disclosure.

FIG. 5 illustrates exemplary locality reporting according to anembodiment of the present disclosure.

FIG. 6 depicts a plan tree structure according to embodiments of thepresent disclosure.

FIG. 7 depicts an exemplary directed acyclic graph of high leveloperators according to an embodiment of the present disclosure.

FIGS. 8A-B depict time estimates according to embodiments of the presentdisclosure.

FIG. 9 depicts a computing node according to an embodiment of thepresent invention.

DETAILED DESCRIPTION

Large-scale analytics on top of MapReduce (MR) is becoming more and moreimportant for many organizations in order to gain value from hugeamounts of collected data. Declarative machine learning (ML) on top ofMapReduce (MR) may exploit data parallelism. The data-parallel MRparadigm does not inherently support task parallelism. However, many usecases in machine learning such as descriptive statistics, crossvalidation or ensemble learning would benefit from task parallelism.Moreover, requiring the user to choose a task parallelization strategyupfront, i.e., an appropriate large-scale algorithm implementation isoften difficult in ad-hoc analysis scenarios. Given a variety of usecases and workloads, there is a strong need for different executionstrategies and automatic optimization.

According to various embodiments of the present disclosure, a systematicapproach for combining task and data parallelism for large-scale machinelearning on top of MapReduce is provided. A dedicated ParFOR (parallelfor) construct is employed, such as may be used in high-performancecomputing (HPC). Optimal parallel execution plans are automaticallycreated during runtime. The present disclosure includes methods for: (a)complementary ParFOR runtime strategies on top of map reduce; (b)access-aware data partitioning and data locality, (c) a memory- andtime-based cost model for arbitrary ML programs, and (d) an optimizationframework for finding the optimal parallel execution plan of a ParFOR MLprogram, including a heuristic optimizer as one embodiment of thisgeneral optimization framework.

Large-scale data analytics has become an integral part of onlineservices (e-commerce, social media), enterprise data management, systemmanagement, and scientific applications (physics, biology, astronomy) inorder to gain value from huge amounts of collected data. Findinginteresting unknown facts and patterns often requires analysis of a fulldata set instead of applying sampling techniques. This challenge may beaddressed by leveraging parallel programming paradigms such as MapReduce(MR), its open-source implementation Hadoop, or more general data flowabstractions. These frameworks enable large-scale, fault-tolerant, andcost-effective parallelization on commodity hardware. Furthermore,high-level languages may be used in order to overcome the complexity ofmultiple MR jobs per query. Examples of such languages include Jaql,Pig, and Hive, each of which may compile queries to MR jobs. Thus, theselanguages may provide low programming effort and good out-of-the-boxperformance.

In addition to analyzing big data, large-scale analytics is driven bythe increasing need for advanced analytics beyond traditionalaggregation queries, in terms of machine learning (ML) and contentanalysis. These analytics range from descriptive statistics to datamining techniques such as clustering, classification, association rulemining, and forecasting. Typical applications are log and salesanalysis, recommendations, and user classifications. While statisticaltools such as R and Matlab may provide analysis libraries, they are notdesigned for distributed computing on big data. Integrating such toolsinto higher-level languages requires that the user to choose aparallelization strategy, i.e., an appropriate large-scale algorithmimplementation, upfront, which is often difficult in ad-hoc analysisscenarios.

SystemML enables declarative machine learning. Complex ML algorithms areexpressed in a high-level language—including linear algebraoperators—called DML (Declarative Machine learning Language) and finallycompiled to programs of MR jobs. This is comparable to high-levellanguages such as Jaql, Pig, and Hive but domain-specific for machinelearning. Advantages of this approach include flexible specification oflarge-scale ML algorithms and automatic cost-based optimization.

An ML system on top of MapReduce faces the following two challenges.First, for small datasets, MR performance is often orders of magnitudeworse than parallel in-memory computation. The reasons includedistributed operator implementations, distributed/local file system I/O,and MR framework overhead. Second, the data-parallel MR paradigm doesnot inherently support task parallelism for compute intensive workloads.However, there are many use cases such as descriptive statistics, crossvalidation, or ensemble learning that would strongly benefit from taskparallelism. One challenge is to provide efficiency and scalability forthe full spectrum from many small to few very large tasks. Both problemsof in-memory computations and task parallelism are inter-related due tomemory constraints and can be jointly solved in a generic cost-basedoptimization framework according to embodiments of the presentdisclosure.

With reference now to FIG. 1, an exemplary SystemML Architectureaccording to embodiments of the present disclosure is shown. MLalgorithms are expressed in a high-level language with R-like syntax—theDeclarative Machine learning Language (DML). DML scripts 101 are parsedto an internal representation of hierarchically structured statementblocks and statements 102, where statement blocks are defined by theprogram structure. Each statement block is then compiled into DAGs ofhigh-level operators (HOPs) 103, low-level operators (LOPs) 104, andfinally to runtime plans of executable program blocks 105 andinstructions 106-107. At each step of this compilation process,different optimizations 108 are applied. Examples include constantfolding/propagation, common subexpression elimination (CSE), operatorordering, operator selection, recompilation decisions, and piggybacking(packing multiple instructions into a single MR job). At runtime level,the control program 109 executes the hierarchy of program blocks andinstructions. Instructions are either CP (control program) instructions106 that are locally executed in-memory of the master process, or MRinstructions 107 that are executed as part of generic MR jobs 110 on aMapReduce cluster 111 such as Hadoop, submitted via MR-job instructions.MR instructions 107 work on blocks of the overall matrix. The exchangeof intermediate results between MR jobs 110 and CP instructions 107 isdone via file exchange over the distributed file system 112 (e.g.,HDFS). A multi-level buffer pool controls this exchange and in-memorymatrices. During runtime, there are again several optimizationsincluding decisions on dense/sparse matrix block representations anddynamic recompilation.

In an example illustrating an execution model according to an embodimentof the present disclosure, Pearson's Correlation Coefficient is computed(r_(X,Y)=co

(X,Y)/σ_(X)σ_(Y), where X and Y are two mx1 vectors). In DML, the twodatasets are read from HDFS, and the standard deviations are computedvia the square root of the second central moment, the covariance of X, Yis computed and finally the correlation coefficient is written to HDFS.An exemplary script is provided at Inset 1.

-   -   X=read(“./input/X”);    -   Y=read(“./input/Y”);    -   m=nrow(X);    -   sigmaX=sqrt(centralMoment(X,2)*(m/(m−1.0)));    -   sigmaY=sqrt(centralMoment(Y,2)*(m/(m−1.0)));    -   r=cov(X,Y)/(sigmaX*sigmaY);    -   write(r,“./output/R”);

Inset 1

Referring to FIG. 2*, since this script is parsed to a single statementblock, a single HOP DAG is created. For example, the statementr=cov(X,Y)/(sigmaX*sigmaY) is compiled to three binary operators (e.g.,b(/) 201, b(cov) 202, b(*) 203) as part of this DAG 200. On LOP level,an execution strategy per operator is decided upon. If X and Y fit inmemory, those three HOPs may be compiled into a partial LOP DAG ofBinaryCP (/), CoVariance, and BinaryCP (*). Otherwise, the HOP b(cov)would be compiled to a LOP chain of CombineBinary (aligns blocks of Xand Y) and CoVariance (computes covariance incrementally). Finally, aprogram block of executable CP/MR instructions is created, in whichmultiple MR instructions are packed into shared MR jobs. At runtime,this program is sequentially executed with materialized intermediatesbetween instructions.

This execution model exploits data parallelism via MR instructionswhenever useful but results in a serial execution of independent taskssuch as independent iterations. Hybrid ParFOR parallelization strategiesare therefore provided herein for combining both task and dataparallelism.

An exemplary taxonomy of task-parallel ML programs is provided inTable 1. This taxonomy provides a basis for reasoning about classes ofuse cases. In this context, data parallelism refers to operator- orDAG-level parallelization, i.e., executing an operation on blocks ofmatrices in parallel. In contrast, task parallelism refers toprogram-level parallelization, i.e., executing a complex ML program oniterations in parallel. The taxonomy of Table 1 employs twoperspectives: model- and data-oriented. First, the model-orientedperspective describes the ML-algorithm-specific statistical model.Multiple (independent) models inherently exhibit large potential fortask parallelism. Examples are cross-validation (CV) or ensemblelearning (EL). There are also many use cases of single composablemodels, i.e., decomposable problems and aggregation of submodels thatbenefit from task parallelism. Example classes are (1) algorithms instatistical query model (SQM) summation form, (2) partitioned matrixfactorization via alternating least squares (ALS), expectationmaximization (EM), or stochastic gradient decent (SGD), and (3)tree-based algorithms like decision trees or Cascade support vectormachines (SVMs). Second, the data-oriented view describes the dataaccess characteristics of iterations, which may use disjoint,overlapping, or all data. Those data categories define applicableoptimizations such as partitioning (disjoint/overlapping) andmemoization/sharing (overlapping/all).

TABLE 1 Single Model Multiple Models Disjoint Data SQM, Data Gen., SGDUnivariate Stats, Indep. Models Overlap. Data SQM, C. SVM, ALS, EM,Bivariate Stats, Meta, CV SGD* All Data Dist.-based, kNN, EL Meta, EL

At the language-level, ParFOR is provided as a high-level DML primitivefor task parallelism. To assist in the below discussion of its parallelexecution and optimization strategies, a running example of atask-parallel DML script is provided.

Inset 2 provides an extension of the correlation script of Inset 1,providing parallel correlation computation for all n(n−1)/2 pairs ofcolumns of an m×n input matrix D. It will be appreciated that this usecase is analogous to cases involving more complex bivariate statistics.

-   -   D=read(“./input/D”);    -   m=nrow(D);    -   n=ncol(D);    -   R=matrix(0, n, n);    -   parfor(i in 1:(n−1)) {        -   X=D[,i];        -   m2X=centralMoment(X,2);        -   sigmaX=sqrt(m2X*(m/(m−1.0)));        -   parfor(j in (i+1):n) {            -   Y=D[,j];            -   m2Y=centralMoment(Y,2);            -   sigmaY=sqrt(m2Y*(m/(m−1.0)));            -   R[i,j]=cov(X,Y)/(sigmaX*sigmaY);        -   }    -   }    -   write(R,“./output/R”);

Inset 2

The outer ParFOR loop iterates from 1 to (n−1) and computes σ for thefirst column. Due to symmetry of r_(X,Y), the inner loop only iteratesfrom (i+1) to n in order to compute r_(X,Y) for all pairs of columns.Below, R[i,j]=v and v=D[,i] are referred to as left and right indexing,respectively. The result is an upper-triangular matrix R.

Given a variety of use cases and workloads, there is a strong need fordifferent parallel execution strategies. For example, if there are manysmall pairs, distributed in-memory computation may be preferable, but ifthere are few very large pairs, scalable data-parallel computation maybe more important. Additional challenges of this example include: (1) atriangular nested loop structure, (2) a column-wise data access onunordered data, and (3) a bivariate all-to-all data shuffling pattern.Thus, complex ParFOR programs and ad-hoc data analysis with unknowninput characteristics require automatic optimization.

Given a ParFOR body denoted prog, a ParFOR predicate p=([a, b], z) withlower bound a, upper bound b and increment z, as well as a clusterconfiguration cc, find a parallel execution plan that minimizes theexecution time T with Equation 1, where k is the degree of parallelism,m is the memory consumption, and ck, cm being constraints. Note that thepredicate p defines N=[(b−a+1)/z] iterations, where a single iterationexecutes prog exactly once for a specific value of the index variableand prog(p) must create correct resultsφ₁: minT(prog(p))s.t. k≦ck^m≦cm  Equation 1

In order to guarantee result correctness for parallel execution, a loopdependency analysis is applied. Extended HPC compiler techniques areemployed. For ensuring determinism and independence, the existence ofany inter-iteration (loop-carried) dependencies is disproved. Acandidate-based algorithm is applied based on the conceptual frameworkof linear functions. First, a set of dependency candidates C iscollected, where a candidate c∈C is defined as a write to a non-localvariable. Second, each candidate c∈C is checked via a sequence of tests(scalar, constant, equals, GCD/Banerjee) against all written and readvariables of the ParFOR body. If independence for c cannot be proved, itis added to C′. For range/set indexing, artificial index variables andbounds are introduced according to the given range. By combining thisinto the linear function, the existing tests can be transparentlyapplied. Third, if C′=Ø, there is no loop-carried dependency and thetest succeeds; otherwise, an error is raised.

The spectrum of use cases is supported with complementary ParFORparallelization strategies. They all adhere to the conceptualmaster/worker pattern: iterations are logically grouped to tasks W, kparallel workers execute those tasks, and finally worker results aremerged.

Task partitioning groups iterations to tasks with the contradictoryobjectives of: (1) low task communication overhead (via few tasks) and(2) good load balance (via many tasks). For example, on MapReduce, tasksetup can take seconds. However, many tasks may be required to exploitlarge clusters. Load balancing is crucial because the mosttime-consuming worker determines the overall execution time. A taskw_(i)∈W may be modeled as a logical group of one or many (sequentiallyexecuted) iterations with task size l_(i)=|w_(i)|, where all iterationsof one task are executed sequentially. Additionally, W is defined as aset of disjoint tasks that exactly cover predicate p.

Fixed-size task partitioning creates tasks with constant size l_(i)=cl,which represents a tradeoff between communication overhead and loadbalancing One extreme is naïve task partitioning with minimal task sizesof l_(i)=1 that leads to very good load balance but high communicationoverhead. Another extreme is static task partitioning with maximal tasksizes of l_(i)=┌N/k┐ that leads to very low communication overhead butpotentially poor load balance.

Additionally, in some embodiments, a factoring self-scheduling algorithmfrom the area of HPC is applied. Waves of exponentially decaying tasksizes are used in order to achieve low communication overhead via largetasks at the beginning but good load balance via few small tasks at theend. Factoring computes the task size li for the next wave of k tasks,based on remaining iterations as shown in Equation 2, with x_(i)=2 assuggested for unknown variability. As an example, N=101 and k=4 resultsin a sequence of (13, 13, 13, 13, 7, 7, 7, 7, 3, 3, 3, 3, 2, 2, 2, 2, 1)iterations. For specific scenarios, this may be extended constrainedC⁻/C⁺ Factoring that additionally imposes either a minimum constraintl_(i)′=max(l_(i), cmin) (e.g., for reduced communication overhead) or amaximum constraint l_(i)′=min (l_(i), cmax) (e.g., for upper-boundedmemory usage). Regarding communication overhead it is noteworthy that |

| increases only logarithmically in N with O(k log_(x) N/k).

$\begin{matrix}{{R_{0} = N}{R_{i + 1} = {R_{i} - {k \cdot l_{i}}}}{l_{i} = {\left\lceil \frac{R_{i}}{x_{i} \cdot k} \right\rceil = \left\lceil {\left( \frac{1}{x_{i}} \right)^{i + 1}\frac{N}{k}} \right\rceil}}} & {{Equation}\mspace{14mu} 2}\end{matrix}$

Factoring differs from guided self-scheduling, as used in OpenMP, inexecuting waves of tasks with equal size, which is more robust andnaturally fits the MR execution model.

For task communication and execution, set and range tasks are supported.Set tasks contain one or many values of the index variable, while rangetasks encode a sequence of values via a (from, to, increment)-triple forcompression if l_(i)>3.

With reference to FIG. 3A, embodiments of the present embodiment includeLOCAL ParFOR (ParFOR-L) execution as a first runtime strategy. Thisruntime strategy addresses the need for generality in terms of taskparallelism for arbitrary body programs and arbitrary data sizes. Thisstrategy exploits multicore parallelism by executing tasks concurrentlyas local threads within the JVM of control program 109 (e.g., SystemML'scontrol program). This enables parallel execution within a single nodewith very low overhead and its generality allows arbitrary instructionsand nested parallelism in the ParFOR body.

FIG. 3A illustrates the runtime architecture of ParFOR-L. First, kparallel workers 311 a . . . k are initialized, a task queue 312 iscreated, and the workers are started as threads that continuouslydequeue and execute tasks until no more tasks are available. Second,task partitioning 313 is performed and tasks are enqueued to the taskqueue 312. Using streaming task creation allows the memory consumptionof this task queue to be upper-bounded. Third, all worker threads arejoined to wait for finished ParFOR execution. Fourth, all worker resultsare aggregated 314.

Local Parallel Workers 311 a . . . k are continuously running threadsthat execute one task—and internally one iteration—at-a-time until nomore tasks are available in the task queue. Each worker gets a deep copyof the ParFOR body, i.e., program blocks and instructions with uniquefile-names, and a shallow copy of the symbol table in order to ensureisolated intermediate results. Due to shared address space andcopy-on-write semantics in SystemML in some embodiments, a shallow copyof the symbol table is sufficient, i.e., input matrices need not becopied. Every write, then creates a new variable and replaces thereference to the shared variable within the worker-local symbol table.

Task Scheduling assigns tasks to workers and is important for reducingwait times. The single task queue for all tasks of a ParFOR is aself-scheduling approach. Since workers dequeue the next task wheneverthey finished a task, temporal gaps between task execution are very low.The pull-based task scheduling also leads to a good load balance, whichstill depends on task partitioning because it determines the schedulinggranularity. Finally, this approach reduces the communication andscheduling overhead to a single synchronized dequeue operation per task.

In some embodiments, Dynamic Recompilation re-optimizes HOP DAGs duringruntime according to the actual matrix characteristics. This enableshandling of initial unknowns. ParFOR-L includes two extensions: First,we evenly divide the context memory budget among the k worker threads.Second, there is the danger of lock contention on the single HOP DAG.Hence, we create deep copies of relevant DAGs for each worker and thusenable concurrent recompilation.

In order to complement the generality of local parallelism (ParFOR-L asdescribed above) with distributed in-memory computation, a secondruntime strategy is provided: REMOTE ParFOR (ParFOR-R). In ParFOR-R,ParFOR itself is executed as a single MR job and its body is executed asin-memory CP instructions, distributed on all nodes of the cluster. Thisensures scalability for large or compute-intensive problems.

The runtime architecture of ParFOR-R according to embodiments of thepresent disclosure is shown in FIG. 3B. First, task partitioning 321 isperformed, and the task sequence is serialized into a task file 322 onHDFS. Second, all dirty—i.e., not up-to date—required input matrices areexported to HDFS. Third, the ParFOR program body, i.e., program blocks,instructions, and referenced DML/external functions, a shallow copy ofthe symbol table, and internal configurations are serialized and storedin the MR job configuration. Fourth, the MR job is submitted and itssuccessful execution is awaited. Result matrices of individual tasks aredirectly written to HDFS but (varname, filename)-tuples are collected inthe job output. This ensures output flexibility with fault tolerance.Fifth, results are aggregated 323.

ParFOR-R is a map-only MR job whose input is the task file with oneParFOR task per line. In some embodiments, the NLineInputFormat is usedin order to initiate one map task per ParFOR task. The number of maptasks is therefore directly controlled via task partitioning 321, wherek is equal to the number of map slots in the cluster.

Remote Parallel Workers 324 a . . . k behave like local workers 311 a .. . k, except for realizing the MR mapper interface. The worker isinitialized by parsing the serialized program and creating programblocks, instructions, and a symbol table with unique file names. On eachmap, the given task is parsed, the program is executed for alliterations of that task, and result variables are written to HDFS. IfJVM reuse is enabled, workers are reused in order to reuse cached inputmatrices and pre-aggregate results. Finally, MR instructions (nested MRjobs) are not allowed inside a remote worker because this incurs thedanger of deadlocks if all map slots are occupied by ParFOR.

In some embodiments, task scheduling is handed over to a MapReducescheduler (e.g., the Hadoop scheduler). The scheduler provides globalscheduling for (1) the task- and data-parallel jobs, as well as (2)other MR-based applications on a shared cluster. This approach providesMR functionality such as fault tolerance, data-locality, and an existingeco-system. In some embodiments, default schedulers such as fifo,capacity and fair schedulers may be used. In other embodiments, customschedulers may be used. Since Hadoop sorts and executes input splits bydecreasing size, in some embodiments we ensure the order of the ParFORtasks by padding range tasks with leading zeros to a constant size oflog₁₀(b)+1, where b refers to the upper bound b of the ParFOR predicatep.

The generality of ParFOR allows the combination of parallel executionmodels as needed. Exemplary hybrid parallelization strategies areillustrated in FIGS. 4A-C, where hybrid refers to combing (1) task anddata parallelism, (2) in-memory and MR computation, and (3) multi-coreand cluster parallelism.

Referring to FIG. 4A, a parallelization strategy for Parallel MR jobsaccording to an embodiment of the present disclosure is illustrated. Ifthe ParFOR body contains operations on large data, in-memory operationscannot be run via ParFOR-R. However, ParFOR-L 411 exploits multi-coreparallelism for CP and MR-job instructions, and hence can run parallelMR jobs 412, 413. This is beneficial for latency hiding and fullresource exploitation. In the example of a 10⁹×5 matrix D, i.e., 10pairs of 2·8 GB each, two nested ParFOR-L instance would be run. Thus,MR jobs for indexing, covariance and central moment of all pairs run inparallel. The best configuration (e.g., number of reducers) depends onthe ParFOR degree of parallelism k, and additional piggybackingopportunities across iterations may be possible.

Referring to FIGS. 4B-C, a parallelization strategy for mixed nestedparallelism according to embodiments of the present disclosure isillustrated. In the case of nested ParFOR, where only the outer containsan MR-job instruction, ParFOR-R 422, 423 may be used for the inner. Thisleads to parallel ParFOR MR jobs, in parallel to the MR jobs from theouter. If there are only CP instructions, a ParFOR-R 431 may be used forthe outer. Within those map tasks, multi-threaded ParFOR-L 432, 433 mayadditionally be used for the inner to exploit all resources.

The hybrid parallelization schemes presented in FIGS. 4A-C areexemplary. Alternative hybrid strategies may be adopted withoutdeparting from the present disclosure. Hybrid strategies provide theflexibility of creating efficient execution plans for complex MLalgorithms.

After local or remote execution, all worker results are consolidated,which contributes to usability and performance. Result variables are thedependency candidates C, i.e., updated, non-local matrices. Independenceimplies that worker results are disjoint. Two scenarios may bedistinguished, in both of which the original result matrix R stillexists due to copy-on-write. First, if R is empty, copying all non-zerovalues from all workers into the final result is all that is necessary.Second, if R is non-empty, copying all (zero and non-zero) values thatdiffer from the original ones must be copied. One example is distributedmatrix factorization, where subblocks may be we iteratively modified inparallel. These two cases are referred to as being with and withoutcompare.

In various embodiments of the present disclosure, aggregation may beperformed according to several schemes: (1) local in-memory, (2) localfile-based, or (3) parallel remote result aggregation. Local in-memorypins R into memory, creates the compare matrix if necessary, and mergesall worker results one-at-a-time. This can be done in parallel andlock-free if R is dense; otherwise merging may be performed serially.Local file-based uses a virtual staging file of directly accessibleblocks, which can be viewed as a radix sort of blocks. This out-of-corealgorithm maps worker result blocks and potentially compare blocks tothat structure, and finally merges one result block at-a-time. Parallelremote uses a dedicated MR job whose inputs are the worker results andif necessary the compare matrix. Mappers then tag blocks as data orcompare, while reducers get the compare block and then merge one blockat-a-time.

The above described runtime already provides high efficiency forcompute-intensive workloads. According to various embodiments of thepresent disclosure, various additional runtime optimizations may beemployed for very large input matrices.

For large matrices, i.e., if the memory consumption of an operationexceeds the memory budget of the master node, that operation is executedas an MR instruction in order to ensure robustness. In this case,ParFOR-R cannot be executed, and so at least one MR job is executed periteration and thus, potentially many MR jobs that repeatedly scan theentire data. While there may often be very large input matrices,individual ParFOR iterations work only on rows, columns or blocks ofmoderate size. In those scenarios, the MR job for repeated indexedaccess is one of the most expensive operations. To optimize suchscenarios, several strategies are adopted: (1) to transparentlypartition the input matrix according to the access pattern and (2) torewrite the body to direct indexed access of partitions.

Data partitioning is only applied for read-only matrices and pure row-or column-wise access patterns. This ensures that no operation otherthan indexed access is affected. For each input matrix D, all accessesin the ParFOR body are recursively analyzed. If there is a commonrow-wise or column-wise pattern, this becomes the partitioning scheme. Dis then partitioned accordingly into directly accessible files and indexaccesses are recompiled with a forced execution depending on thepartition size.

According to various embodiments, partitioning may be performed as localfile-based or parallel remote partitioning, both of which create oneSequenceFile per partition. Local file-based is a two-phase out-of-corealgorithm that reads the input, appends blocks to a partitioned stagingfile, and finally creates a partitioned matrix. Parallel remote is adedicated MR job, where mappers do the partitioning on a block level andreducers write partitions. For high performance of partitioning andread, block-wise partitioning (groups of rows or columns) is alsosupported, with a block size according to the HDFS block size.

Since ParFOR-R uses a task file as the input, Hadoop cannot co-locaterelevant map tasks to the input matrices or partitions. This leads tounnecessary data transfer because, especially on large clusters, datalocal access become unlikely.

Referring to FIG. 5, exemplary Locality Reporting for X=D[,i] isillustrated. Location information of relevant matrices and partitionsper logical task is explicitly provided in order to enable datalocality. This is provided for the largest partitioned input matrix thatis accessed via the iteration variable. A dedicated input format (e.g.,a specialized NLineInputFormat) and input split (e.g., a specializedFileSplit) are used. Whenever splits are requested from this inputformat, the matrix partitioning information is analyzed and a wrappersplit is created around each original file split. Instead of reportingthe location of the small task file splits: (1) the logical task (oneper split) is parsed, (2) locations of all related partition files aredetermined, (3) frequencies are counted, and (4) the top-k frequentnodes are reported as locations. Since Hadoop treats all reportedlocations equally, in some embodiments, only the hosts with top-1frequency are reported as shown in FIG. 5. For range tasks, heuristicanalysis is performed only of locations of the first and last iterationbecause locality is examined serially before job submission.

During initial compilation, important matrix characteristics and theParFOR problem size N might be unknown. In some embodiments, ParFORoptimization is therefore applied as a second optimization phase atruntime for each top-level ParFOR. The plan representation and relatedoptimization problem may be defined in terms of a plan tree.

A Plan Tree P is a tree of nodes n∈

_(P) with height h, modeling ParFOR and its body prog. Inner nodes areprogram blocks and refer to an unordered set of child nodes c(n), whereedges represent containment relationships. Leaf nodes are operations.Nodes have a node type nt, an execution type et, a degree of parallelismk, and specific attributes A. P spans a non-empty set of executioncontexts

_(P), where the root node r(P) and specific et define a context withmemory cm_(ec) and parallelism ck_(ec) constraints. Shared resources areglobal constraints.

Referring to FIG. 6, a plan tree structure may be used to representarbitrary ParFOR programs. FIG. 6 shows the plan tree P of a runningexample Inner nodes refer to ParFOR 501 and generic program blocks 602;leaf nodes 611 a . . . n, 621 a . . . n refer to operations (HOPs inthis case). The root node 603 defines the context of the master processwith its constraints (e.g., the max JVM size). Since the nested ParFOR601 has et=MR, there is a second context of the map task process. Thereexists a mapping from nodes in P to HOP DAGs and runtime plans.

The plan tree optimization problem may be defined in terms of the plantree. Given an initial plan tree P, which is assumed to be the optimalsequential plan per program block, transform P into a semanticallyequivalent plan tree P′ that is optimal w.r.t. Equation 3.φ₂:min {circumflex over (T)}(r(P))s.t. ∀ec∈

_(P) :{circumflex over (M)}(r(ec))≦cm _(ec) ^K(r(ec))≦ck _(ec)  Equation3

Thus, the goal is to minimize the execution time of the plan tree's rootnode {circumflex over (T)}(r(P)) under the hard constraints of maximumtotal memory consumption {circumflex over (M)}(r(ec)) and maximum totalparallelism K(r(ec)) per execution context ec. Valid transformations arenode operator selection (et), node configuration changes (k, A), andstructural changes of P.

In contrast to alternative query optimization, P covers (1) a complex MLprogram with control flow, linear algebra operators, task and dataparallelism, which require dedicate rewrites and cost modeling, and (2)hard constraints, which require dedicated search strategies and costestimation.

The plan tree optimization problem is a multiple knapsack problem withmultiple constraints, which is known to be NP-hard. Its specificproperties are a variable hierarchy of items and knapsacks, as well asmultiple variable capacity constraints. In detail, n is an item and{circumflex over (T)}(n) is the item value. Each context ec defines aknapsack with constraints em_(ec) and ck_(ec). P with

_(P) defines the item and knapsack hierarchies, where multiple knapsacksshare common constraints (e.g., cluster parallelism).

As a precondition for optimization, a cost model and accurate estimatesare required. According to objective φ₂, there are differentrequirements on those estimates. A soft constraint is imposed onexecution time. However, worst-case estimates for memory and parallelismare necessary to guarantee those hard constraints, This is important forpreventing out-of-memory situations. Furthermore, the analytical costmodel should allow costing arbitrary plan alternatives.

Memory estimation for leaf nodes of a plan tree works on HOP DAGs.Estimates are provided for CP operations as well as block computationsin MR. For each DAG, a bottom-up approach of recursively propagatingmatrix characteristics and estimating memory is used.

Matrix characteristics for memory estimates include the matrixdimensions d₁, d₂ and the matrix sparsity d_(s). For worst-case memoryestimates, worst-case estimates for those characteristics are alsorequired. Fortunately, many operators of linear algebra (e.g., matrixmultiplication) allow to exactly infer their output dimensions.Inferring the sparsity is more difficult due to potential skew but thereare, for example, sparsity preserving operations such as s·X(s∉0, NaN,∞). Finally, for unknown characteristics, it is assumed that d₁=∞, d₂=∞and d_(s), =1.

Based on worst-case matrix characteristics, which have been propagatedthrough the DAG, the output memory {circumflex over (M)}(out(n)) andoperation memory {circumflex over (M)}(n) may be computed according toEquation 4, where dense matrices are double arrays and sparse matricesuse compressed rows of (column index, value)-pairs. This estimatereflects the runtime model of CP instructions that pin all inputs andoutputs in memory. Hence, the memory estimate is the sum of all input,intermediate (depending on intra-operation parallelism k), and outputsizes.

$\begin{matrix}{{{\hat{M}(n)} = {{\sum\limits_{\forall\;{c \in {{in}{(n)}}}}^{\;}{\hat{M}\left( {{out}\left( c_{i} \right)} \right)}} + {\hat{M}\left( {n,k} \right)} + {\hat{M}\left( {{out}(n)} \right)}}}{{\hat{M}\left( {{out}(n)} \right)} = \left\{ \begin{matrix}{d_{1}\left( {{116\; B} + {12\;{B \cdot d_{2}}d_{s}}} \right)} & {sparse} \\{8\;{B \cdot d_{1}}d_{2}} & {dense}\end{matrix} \right.}} & {{Equation}\mspace{14mu} 4}\end{matrix}$

FIG. 7 depicts part of the HOPs DAG of the above example's inner ParFOR.Assume a 10⁶×10 input matrix D 701 with sparsity d_(s)=1. Accordingly,the output size of IX 702 is estimated as 8 MB and the operation memoryas 88 MB.

The worst-case memory estimate of a leaf node of P is then defined asthe operation memory estimate {circumflex over (M)}(n) of its mapped HOPif et=CP and as a constant M^(C) if et=MR because then it is executed ina separate context.

To make an accurate estimate of time for leaf nodes of a plan tree,runtime properties of operators must be taken into account. Thus, thebelow detailed approach leverages offline performance profiling ofruntime instructions, performed once for a cluster configuration.

Performance profiling measures {circumflex over (T)} of all relevantinstructions Op for a set of variables

, where we vary one variable

∈

at-a-time. Different execution types and matrix representations aremodeled as different instructions. Polynomial regression models arecreated as cost functions C_(T,Op)(v) for each (v,Op)-combination. Theprofile is the set of C_(T,Op)(v) for all

∈

.

For a request Q with ∀v∈V: ∃p(v)∈Q, {circumflex over (T)}, wheref_(x)(q_(x)) is a shorthand for C_(T,Op)(x=q_(x)).

$\begin{matrix}{{\hat{T}\left( {Q,} \right)} = {{f_{d}\left( {q_{d},} \right)} \cdot {\prod\limits_{\forall{x \in {({Q - d})}}}^{\;}\;{\frac{f_{x}\left( {q_{x},} \right)}{f_{x}\left( {d_{x},} \right)} \cdot {{corr}(Q)}}}}} & {{Equation}\mspace{14mu} 5}\end{matrix}$

Scaling one-dimensional cost functions makes a fundamental independenceassumption, which is important for efficient profiling but can lead tolow accuracy. Correction terms based on ratios of number of floatingpoint operations are therefore used, e.g., for matrix shape adjustments.This correction enables high accuracy due to a shape-dependentasymptotic behavior. For example, consider a matrix multiplication AB,where each matrix has 10⁶ cells, i.e., 8 MB. Multiplying two 1,000×1,000matrices requires 2 GFlop, while a dot product of 10⁶×1 vectors requiresonly 2 MFlop, i.e., a relative difference of 10³. Thus, scaled costfunctions allow the accurate estimation of time, even for differentbehavior of dense/sparse operations.

Referring to FIG. 8, time estimates are depicted according toembodiments of the present disclosure. Assume a query Q withq_(d)=700,000 (q_(d1)=1,000, q_(d2)=700), and q_(s)=0.7 for CP, dense,transpose-self matrix multiplication X^(T)X. Further, assume costfunctions for datasize f_(D)(d) and sparsity f_(S)(s), created withsquared matrices and defaults d_(d)=500,000 and d_(s)=0.5. First, f_(D)is picked as the leading dimension, yielding f_(D)(q_(d))=325 ms. Thenit is scaled to {circumflex over (T)}(q_(d), q_(s))={circumflex over(T)}(q_(d))·f_(s)(q_(s))/f_(s) (d_(s))=438 ms as shown in FIG. 8. Then,a correction is performed: {circumflex over (T)}={circumflex over(T)}(q_(d), q_(s))·corr(Q), yielding {circumflex over (T)}=366 ms.Finally, the time estimates are assigned from mapped HOPs andinstructions to plan tree leaf nodes again.

Memory and time estimates for arbitrary complex programs may bedetermined by aggregating leaf node estimates. The worst-case estimateof memory consumption for a ParFOR node is computed with Equation 6 asthe number of workers times the most-memory consuming operation sincethose operations are executed sequentially.

$\begin{matrix}{{\hat{M}(n)} = \left\{ \begin{matrix}\left. {k \cdot {\max\limits_{\forall{c \in {c{(n)}}}}\hat{M}}} \middle| (c) \right. & {{et} = {CP}} \\M^{C} & {{et} = {MR}}\end{matrix} \right.} & {{Equation}\mspace{14mu} 6}\end{matrix}$

The memory estimate for all other inner-nodes (for, while, if, func, andgeneric) is {circumflex over (M)}(n)=max_(∀c∈c(n)){circumflex over(M)}(c). One challenge is to incorporate shared reads into memoryestimates in order to prevent large overestimation. This is done bysplitting {circumflex over (M)} into shared {circumflex over (M)}⁺ andnon-shared {circumflex over (M)}⁻ parts and scaling {circumflex over(M)}⁺ by the number of consumers.

Average-case time estimates are similarly aggregated as the sum of childnode time estimates due to sequential execution. In detail, the timeestimates are given by Equation 7. Since {circumflex over (N)} cannot bedetermines for while and unknown for/parfor, it is estimated as aconstant {circumflex over (N)}=N^(C) there. This reflects at least thatthe body is likely executed multiple times. Furthermore, the timeestimate of an if is a weighted sum because only one branch is executedat-a-time.

$\begin{matrix}{{{\hat{T}(n)} = {w_{n}{\sum\limits_{\forall{c \in {c{(n)}}}}{\hat{T}(c)}}}},{w_{n} = \left\{ \begin{matrix}\left\lceil {\hat{N}/k} \right\rceil & {parfor} \\\hat{N} & {{for},{while}} \\{1/{{c(n)}}} & {if} \\1 & {otherwise}\end{matrix} \right.}} & {{Equation}\mspace{14mu} 7}\end{matrix}$

Finally, total parallelism is also aggregated withK(n)=k·max_(∀c∈c(n))K(c). For excluding remote parallelism, K(n)=1, ifet=MR.

According to embodiments of the present disclosure, algorithms areprovided for finding optimal parallel execution plans. Due to the largesearch space, a spectrum of optimizers is provided with differentcomplexity. Each optimizer is characterized by: (1) the used cost model,(2) the rewrites that define the search space, and (3) the searchstrategy. In the following, a default heuristic optimizer andrequirements for more advanced optimizers are provided.

An heuristic optimizer according to embodiments of the presentdisclosure uses a time- and memory-based cost model without sharedreads, heuristic high-impact rewrites, and a transformation-based searchstrategy with global optimization scope. The time-based cost modelenables accurate estimates but requires a pre-created profile. If noprofile exists, a memory-based cost model is used and—instead of timeestimates—additional heuristic including that local, in-memorycomputations require less time than their MR alternatives.

The search space is defined by a variety of ParFOR-specific heuristicrewrites. These include rewrites regarding ParFOR parallelizationstrategies and rewrites exploiting repeated, parallel iterationexecution. Examples for ParFOR-centric rewrites include operatorselection such as selecting the ParFOR execution type et (CP/MR, i.e.,ParFOR-L vs ParFOR-R), task partitioning, and result aggregationmethods. Example configuration changes include choosing the degree ofparallelism k and task sizes. Structural plan changes include artificialnested ParFOR for multi-threaded map tasks, unfolding ParFOR inrecursive functions, and changing ParFOR to for. Second, examples foriteration-aware rewrites include operator selection like datapartitioning, where the partitioning format, partitioning method, andexecution type are chosen et of left and right indexing. Exampleconfiguration changes include choosing matrices for co-location, andchanging the partition replication factor r. Most of these rewrites needto take the entire plan tree P into account.

A transformation-based, top-down search strategy may be used thattransforms P and its mapped program into P′. This follows thefundamental heuristic to apply available parallelism as high as possiblein the plan tree to cover more operations and reduce synchronization.This approach uses a well-defined rewrite order. First, data-flowrewrites are applied that change the memory estimates of P. Thisincludes data and result partitioning because related indexedreads/writes are potentially recompiled to in-memory operations. Second,a recursive decision is made—starting at the root of P—on ParFORexecution type and degree of parallelism. Based on memory constraintsand estimates, the maximum parallelism to apply per level can bedirectly computed. Third, for all subtrees rooted by ParFOR,execution-type-specific rewrites are applied. For ParFOR-L this includestask partitioner and recompilation budget, while for ParFOR-R thisincludes data colocation, replication factors, nested ParFOR, and taskpartitioner. Fourth, result merge strategies are decided on, recursivefunctions are handled, and unnecessary ParFOR are recompiled to for. Themajority of rewrites has a complexity of

(|

_(P)|) with exceptions of up to

(|

_(P)|²). This strategy finds the optimal plan according to theheuristically restricted search space but guarantees all constraints ofφ₂.

Referring now to FIG. 8, a schematic of an example of a computing nodeis shown. Computing node 10 is only one example of a suitable computingnode and is not intended to suggest any limitation as to the scope ofuse or functionality of embodiments of the invention described herein.Regardless, computing node 10 is capable of being implemented and/orperforming any of the functionality set forth hereinabove.

In computing node 10 there is a computer system/server 12, which isoperational with numerous other general purpose or special purposecomputing system environments or configurations. Examples of well-knowncomputing systems, environments, and/or configurations that may besuitable for use with computer system/server 12 include, but are notlimited to, personal computer systems, server computer systems, thinclients, thick clients, handheld or laptop devices, multiprocessorsystems, microprocessor-based systems, set top boxes, programmableconsumer electronics, network PCs, minicomputer systems, mainframecomputer systems, and distributed cloud computing environments thatinclude any of the above systems or devices, and the like.

Computer system/server 12 may be described in the general context ofcomputer system-executable instructions, such as program modules, beingexecuted by a computer system. Generally, program modules may includeroutines, programs, objects, components, logic, data structures, and soon that perform particular tasks or implement particular abstract datatypes. Computer system/server 12 may be practiced in distributed cloudcomputing environments where tasks are performed by remote processingdevices that are linked through a communications network. In adistributed cloud computing environment, program modules may be locatedin both local and remote computer system storage media including memorystorage devices.

As shown in FIG. 8, computer system/server 12 in computing node 10 isshown in the form of a general-purpose computing device. The componentsof computer system/server 12 may include, but are not limited to, one ormore processors or processing units 16, a system memory 28, and a bus 18that couples various system components including system memory 28 toprocessor 16.

Bus 18 represents one or more of any of several types of bus structures,including a memory bus or memory controller, a peripheral bus, anaccelerated graphics port, and a processor or local bus using any of avariety of bus architectures. By way of example, and not limitation,such architectures include Industry Standard Architecture (ISA) bus,Micro Channel Architecture (MCA) bus, Enhanced ISA (EISA) bus, VideoElectronics Standards Association (VESA) local bus, and PeripheralComponent Interconnect (PCI) bus.

Computer system/server 12 typically includes a variety of computersystem readable media. Such media may be any available media that isaccessible by computer system/server 12, and it includes both volatileand non-volatile media, removable and non-removable media.

System memory 28 can include computer system readable media in the formof volatile memory, such as random access memory (RAM) 30 and/or cachememory 32. Computer system/server 12 may further include otherremovable/non-removable, volatile/non-volatile computer system storagemedia. By way of example only, storage system 34 can be provided forreading from and writing to a non-removable, non-volatile magnetic media(not shown and typically called a “hard drive”). Although not shown, amagnetic disk drive for reading from and writing to a removable,non-volatile magnetic disk (e.g., a “floppy disk”), and an optical diskdrive for reading from or writing to a removable, non-volatile opticaldisk such as a CD-ROM, DVD-ROM or other optical media can be provided.In such instances, each can be connected to bus 18 by one or more datamedia interfaces. As will be further depicted and described below,memory 28 may include at least one program product having a set (e.g.,at least one) of program modules that are configured to carry out thefunctions of embodiments of the invention.

Program/utility 40, having a set (at least one) of program modules 42,may be stored in memory 28 by way of example, and not limitation, aswell as an operating system, one or more application programs, otherprogram modules, and program data. Each of the operating system, one ormore application programs, other program modules, and program data orsome combination thereof, may include an implementation of a networkingenvironment. Program modules 42 generally carry out the functions and/ormethodologies of embodiments of the invention as described herein.

Computer system/server 12 may also communicate with one or more externaldevices 14 such as a keyboard, a pointing device, a display 24, etc.;one or more devices that enable a user to interact with computersystem/server 12; and/or any devices (e.g., network card, modem, etc.)that enable computer system/server 12 to communicate with one or moreother computing devices. Such communication can occur via Input/Output(I/O) interfaces 22. Still yet, computer system/server 12 cancommunicate with one or more networks such as a local area network(LAN), a general wide area network (WAN), and/or a public network (e.g.,the Internet) via network adapter 20. As depicted, network adapter 20communicates with the other components of computer system/server 12 viabus 18. It should be understood that although not shown, other hardwareand/or software components could be used in conjunction with computersystem/server 12. Examples, include, but are not limited to: microcode,device drivers, redundant processing units, external disk drive arrays,RAID systems, tape drives, and data archival storage systems, etc.

The present invention may be a system, a method, and/or a computerprogram product. The computer program product may include a computerreadable storage medium (or media) having computer readable programinstructions thereon for causing a processor to carry out aspects of thepresent invention.

The computer readable storage medium can be a tangible device that canretain and store instructions for use by an instruction executiondevice. The computer readable storage medium may be, for example, but isnot limited to, an electronic storage device, a magnetic storage device,an optical storage device, an electromagnetic storage device, asemiconductor storage device, or any suitable combination of theforegoing. A non-exhaustive list of more specific examples of thecomputer readable storage medium includes the following: a portablecomputer diskette, a hard disk, a random access memory (RAM), aread-only memory (ROM), an erasable programmable read-only memory (EPROMor Flash memory), a static random access memory (SRAM), a portablecompact disc read-only memory (CD-ROM), a digital versatile disk (DVD),a memory stick, a floppy disk, a mechanically encoded device such aspunch-cards or raised structures in a groove having instructionsrecorded thereon, and any suitable combination of the foregoing. Acomputer readable storage medium, as used herein, is not to be construedas being transitory signals per se, such as radio waves or other freelypropagating electromagnetic waves, electromagnetic waves propagatingthrough a waveguide or other transmission media (e.g., light pulsespassing through a fiber-optic cable), or electrical signals transmittedthrough a wire.

Computer readable program instructions described herein can bedownloaded to respective computing/processing devices from a computerreadable storage medium or to an external computer or external storagedevice via a network, for example, the Internet, a local area network, awide area network and/or a wireless network. The network may comprisecopper transmission cables, optical transmission fibers, wirelesstransmission, routers, firewalls, switches, gateway computers and/oredge servers. A network adapter card or network interface in eachcomputing/processing device receives computer readable programinstructions from the network and forwards the computer readable programinstructions for storage in a computer readable storage medium withinthe respective computing/processing device.

Computer readable program instructions for carrying out operations ofthe present invention may be assembler instructions,instruction-set-architecture (ISA) instructions, machine instructions,machine dependent instructions, microcode, firmware instructions,state-setting data, or either source code or object code written in anycombination of one or more programming languages, including an objectoriented programming language such as Smalltalk, C++ or the like, andconventional procedural programming languages, such as the “C”programming language or similar programming languages. The computerreadable program instructions may execute entirely on the user'scomputer, partly on the user's computer, as a stand-alone softwarepackage, partly on the user's computer and partly on a remote computeror entirely on the remote computer or server. In the latter scenario,the remote computer may be connected to the user's computer through anytype of network, including a local area network (LAN) or a wide areanetwork (WAN), or the connection may be made to an external computer(for example, through the Internet using an Internet Service Provider).In some embodiments, electronic circuitry including, for example,programmable logic circuitry, field-programmable gate arrays (FPGA), orprogrammable logic arrays (PLA) may execute the computer readableprogram instructions by utilizing state information of the computerreadable program instructions to personalize the electronic circuitry,in order to perform aspects of the present invention.

Aspects of the present invention are described herein with reference toflowchart illustrations and/or block diagrams of methods, apparatus(systems), and computer program products according to embodiments of theinvention. It will be understood that each block of the flowchartillustrations and/or block diagrams, and combinations of blocks in theflowchart illustrations and/or block diagrams, can be implemented bycomputer readable program instructions.

These computer readable program instructions may be provided to aprocessor of a general purpose computer, special purpose computer, orother programmable data processing apparatus to produce a machine, suchthat the instructions, which execute via the processor of the computeror other programmable data processing apparatus, create means forimplementing the functions/acts specified in the flowchart and/or blockdiagram block or blocks. These computer readable program instructionsmay also be stored in a computer readable storage medium that can directa computer, a programmable data processing apparatus, and/or otherdevices to function in a particular manner, such that the computerreadable storage medium having instructions stored therein comprises anarticle of manufacture including instructions which implement aspects ofthe function/act specified in the flowchart and/or block diagram blockor blocks.

The computer readable program instructions may also be loaded onto acomputer, other programmable data processing apparatus, or other deviceto cause a series of operational steps to be performed on the computer,other programmable apparatus or other device to produce a computerimplemented process, such that the instructions which execute on thecomputer, other programmable apparatus, or other device implement thefunctions/acts specified in the flowchart and/or block diagram block orblocks.

The flowchart and block diagrams in the Figures illustrate thearchitecture, functionality, and operation of possible implementationsof systems, methods, and computer program products according to variousembodiments of the present invention. In this regard, each block in theflowchart or block diagrams may represent a module, segment, or portionof instructions, which comprises one or more executable instructions forimplementing the specified logical function(s). In some alternativeimplementations, the functions noted in the block may occur out of theorder noted in the figures. For example, two blocks shown in successionmay, in fact, be executed substantially concurrently, or the blocks maysometimes be executed in the reverse order, depending upon thefunctionality involved. It will also be noted that each block of theblock diagrams and/or flowchart illustration, and combinations of blocksin the block diagrams and/or flowchart illustration, can be implementedby special purpose hardware-based systems that perform the specifiedfunctions or acts or carry out combinations of special purpose hardwareand computer instructions.

The descriptions of the various embodiments of the present inventionhave been presented for purposes of illustration, but are not intendedto be exhaustive or limited to the embodiments disclosed. Manymodifications and variations will be apparent to those of ordinary skillin the art without departing from the scope and spirit of the describedembodiments. The terminology used herein was chosen to best explain theprinciples of the embodiments, the practical application or technicalimprovement over technologies found in the marketplace, or to enableothers of ordinary skill in the art to understand the embodimentsdisclosed herein.

What is claimed is:
 1. A method comprising: receiving program codecontaining at least one parallel for statement having a plurality ofiterations; determining a parallel execution plan for the program code,wherein determining the parallel execution plan comprises applying anheuristic optimizer, the heuristic optimizer comprises a cost model, andwherein the cost model includes at least one of an execution time of theprogram code and a memory estimate of the program code; according to theparallel execution plan, partitioning the plurality of iterations into aplurality of tasks, each task comprising at least one iteration, theiterations of each task being independent; determining first datarequired by the plurality of tasks; determining an access pattern by theplurality of tasks of the first data; based on the access pattern,partitioning the first data; providing each of the plurality of tasks toone of a plurality of parallel workers, each of the plurality ofparallel workers being a MapReduce task or a local thread, whereinproviding each of the plurality of tasks to one of the plurality ofparallel workers comprises: determining second data required by a firstof the plurality of tasks; determining that the second data is locallyavailable to a first of the plurality of parallel workers; and providingthe first of the plurality of tasks to the first of the plurality ofparallel workers; receiving from each of the plurality of parallelworkers a result; and aggregating the results from each of the pluralityof parallel workers.
 2. The method of claim 1, wherein: the parallelexecution plan is determined at a runtime of the program code.
 3. Themethod of claim 1, wherein partitioning the plurality of iterationscomprises performing a loop-dependency analysis.
 4. The method of claim1, wherein at least one of the plurality of tasks reads data from adistributed filesystem.
 5. The method of claim 1, wherein each of theplurality of tasks has a size that conforms to an exponential decayfunction.
 6. The method of claim 1, wherein each of the plurality oftasks has a predetermined size.
 7. The method of claim 1, wherein theparallel execution plan includes execution of each of the plurality ofparallel workers on a single node.
 8. The method of claim 1, wherein theparallel execution plan includes execution of each of the plurality ofparallel workers on one of a plurality of nodes.
 9. The method of claim1, wherein the cost model comprises a cost function and the costfunction is determined by linear regression.
 10. The method of claim 1,wherein the program code comprises at least two nested parallel forstatements and wherein the plurality of parallel workers comprises atleast one MapReduce task and at least one local thread.
 11. The methodof claim 1, wherein determining the parallel execution plan comprises:specifying that each of the plurality of tasks be executed eitherlocally or remotely.
 12. The method of claim 1, wherein determining aparallel execution plan includes creating a plan representation, themethod further comprising: traversing the plan representation todetermine a total estimated runtime; traversing the plan representationto determine a total memory consumption, wherein: the parallel executionplan is determined such that it conforms to at least one of a memoryconstraint or a parallelism constraint.
 13. The method of claim 1,wherein applying the heuristic optimizer comprises at least one of:selecting an execution type; selecting a parallel for execution type;selecting data for colocation; changing a replication factor; selectinga task partitioning method; selecting a task size; selecting a degree ofparallelism; replacing parallel for by for; selecting an aggregationstrategy; unfolding recursive functions; determining a data accesspattern; selecting a data partitioning strategy; or recompiling indexedreads and indexed writes.
 14. A computer program product forparallelization, the computer program product comprising a computerreadable storage medium having program instructions embodied therewith,the program instructions executable by a processor to cause theprocessor to: receiving program code containing at least one parallelfor statement having a plurality of iterations; determining a parallelexecution plan for the program code, wherein determining the parallelexecution plan comprises applying an heuristic optimizer, the heuristicoptimizer comprises a cost model, and wherein the cost model includes atleast one of an execution time of the program code and a memory estimateof the program code; according to the parallel execution plan,partitioning the plurality of iterations into a plurality of tasks, eachtask comprising at least one iteration, the iterations of each taskbeing independent; determining first data required by the plurality oftasks; determining an access pattern by the plurality of tasks of thefirst data; based on the access pattern, partitioning the first data;providing each of the plurality of tasks to one of a plurality ofparallel workers, each of the plurality of parallel workers being aMapReduce task or a local thread, wherein providing each of theplurality of tasks to one of the plurality of parallel workerscomprises: determining second data required by a first of the pluralityof tasks; determining that the second data is locally available to afirst of the plurality of parallel workers; and providing the first ofthe plurality of tasks to the first of the plurality of parallelworkers; receiving from each of the plurality of parallel workers aresult; and aggregating the results from each of the plurality ofparallel workers.
 15. The computer program product of claim 14, wherein:the parallel execution plan is determined at a runtime of the programcode.
 16. The computer program product of claim 14, wherein partitioningthe plurality of iterations comprises performing a loop-dependencyanalysis.
 17. The computer program product of claim 14, wherein at leastone of the plurality of tasks reads data from a distributed filesystem.18. The computer program product of claim 14, wherein each of theplurality of tasks has a size that conforms to an exponential decayfunction.
 19. The computer program product of claim 14, wherein each ofthe plurality of tasks has a predetermined size.
 20. The computerprogram product of claim 14, wherein the parallel execution planincludes execution of each of the plurality of parallel workers on asingle node.